package com.lanxiao.cloud.modules.file.controller;

import com.lanxiao.cloud.modules.file.application.UploadCmdManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author ：qiaoliang
 * @date ：2021-10-25
 */
@Api(tags = "文件服务")
@Validated
@RequestMapping("/files")
@RestController
public class UploadController {

  private final UploadCmdManager uploadCmdManager;

  public UploadController(
      UploadCmdManager uploadCmdManager) {
    this.uploadCmdManager = uploadCmdManager;
  }

  @ApiOperation(value = "文件上传")
  @PostMapping
  public String uploadImg(@RequestParam("file") MultipartFile file) {
    return uploadCmdManager.upload(file);
  }

}
